<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<html>
<head>
	<script type="text/javascript" src="scripts/boot.js"></script>
</head>
<body>
	<form id="form1" method="post">
        <div style="padding-left:70px;padding-bottom:5px;padding-top: 25px;">
            <table style="table-layout:fixed;">
            	<tr>
                   	<td style="width: 200px;">
                   		<input id="file_upload" name="file_upload" type="file" >
                   	</td>
                </tr>
            </table>
        </div>
        <div style="text-align:center;padding:40px;">               
            <a class="mini-button" onclick="onOk" style="width:60px;margin-right:50px;">确定</a>       
            <a class="mini-button" onclick="onCancel" style="width:60px;">取消</a>       
        </div>        
    </form>
</body>
</html>

<script type="text/javascript">
	mini.parse();
	
	var form = new mini.Form("form1");
	
	//保存数据
	function SaveData() {
	    var o = form.getData(true); 
	    $.ajax({
	        url: "recall_import_save.do",
			type: 'post',
			dataType: 'json',
	        data: o,
	        cache: false,
	        success: function (text) {
	            if(text.success){
	            	window.CloseOwnerWindow("succ");
	            }else{
	            	mini.alert(text.errorInfo);
	            }
	        },
	        error: function (jqXHR, textStatus, errorThrown) {
	            alert(jqXHR.responseText);
	            window.CloseOwnerWindow();
	        }
	    });
	}

    $(function(){
    	$(function(){
        	setTimeout(function(){
    	    	$('#file_upload').uploadify({
    	    		'auto':false,
    	    		'swf':'scripts/uploadify/uploadify.swf',
    	    		'uploader':'recall_import_save.do;jsessionid=<%=session.getId()%>',
    	    		'fileSizeLimit':'5MB',
    	    		'fileTypeExts':'*.xls',
    	    		'fileTypeDesc':'xls',
    	    		'buttonText':'选择文件',
    	    		'queueSizeLimit':1,
    	    		'onUploadSuccess':function(file, data, response){
    	    			data = eval('(' + data + ')');
    	    			if(data.success){
    		            	window.CloseOwnerWindow("succ");
    		            }else{
    		            	mini.alert(text.errorInfo);
    		            }
    	    		}
    	    	});
        	}, 5);
        });
    });
    
    function onOk(e) {
    	$("#file_upload").uploadify('upload', '*');
    }

    function GetData() {
        var o = form.getData();
        return o;
    }
    
    function CloseWindow(action) {            
        if (window.CloseOwnerWindow) return window.CloseOwnerWindow(action);
        else window.close();            
    }
    
    function onCancel(e) {
    	var filePath = mini.getbyName("filePath").getValue();
       	if(filePath.length > 0){
       		$.post("recall_import_del.do", {filePath: filePath}, function(data){
           		if(data.success){
       		        CloseWindow("cancel");
           		}
           	}, "json");
       	} else {
       		CloseWindow("cancel");
       	}
    }
</script>